package com.ruoyi.web.controller.yf;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yf.domain.YfBucketAndTagOutbound;
import com.ruoyi.yf.service.IYfBucketAndTagOutboundService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医废垃圾桶和条形码关联（一键出库）Controller
 * 
 * @author XiaoYi...
 * @date 2020-03-17
 * 3d84389c-3d0f-4834-9b71-5594ae39c598
 */
@Controller
@RequestMapping("/yf/outbound")
public class YfBucketAndTagOutboundController extends BaseController
{
    private String prefix = "yf/outbound";

    @Autowired
    private IYfBucketAndTagOutboundService yfBucketAndTagOutboundService;

    @RequiresPermissions("yf:outbound:view")
    @GetMapping()
    public String outbound()
    {
        return prefix + "/outbound";
    }

    /**
     * 查询医废垃圾桶和条形码关联（一键出库）列表
     * 5b614145-5a0f-4da7-b389-70e0b8f8e05c
     */
    @RequiresPermissions("yf:outbound:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YfBucketAndTagOutbound yfBucketAndTagOutbound)
    {
        startPage();
        List<YfBucketAndTagOutbound> list = yfBucketAndTagOutboundService.selectYfBucketAndTagOutboundList(yfBucketAndTagOutbound);
        return getDataTable(list);
    }

    /**
     * 导出医废垃圾桶和条形码关联（一键出库）列表
     * 8f4565ab-32d1-48dc-9a1a-e36210c79dc6
     */
    @RequiresPermissions("yf:outbound:export")
    @Log(title = "医废垃圾桶和条形码关联（一键出库）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YfBucketAndTagOutbound yfBucketAndTagOutbound)
    {
        List<YfBucketAndTagOutbound> list = yfBucketAndTagOutboundService.selectYfBucketAndTagOutboundList(yfBucketAndTagOutbound);
        ExcelUtil<YfBucketAndTagOutbound> util = new ExcelUtil<YfBucketAndTagOutbound>(YfBucketAndTagOutbound.class);
        return util.exportExcel(list, "outbound");
    }

    /**
     * 新增医废垃圾桶和条形码关联（一键出库）
     * adafee57-4e2e-4827-8655-ec38c13ab385
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存医废垃圾桶和条形码关联（一键出库）
     * ba1ed7a8-e5ce-499f-86cb-f37d644509e3
     */
    @RequiresPermissions("yf:outbound:add")
    @Log(title = "医废垃圾桶和条形码关联（一键出库）", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YfBucketAndTagOutbound yfBucketAndTagOutbound)
    {
        return toAjax(yfBucketAndTagOutboundService.insertYfBucketAndTagOutbound(yfBucketAndTagOutbound));
    }

    /**
     * 修改医废垃圾桶和条形码关联（一键出库）
     * f550b7dc-3318-4845-8919-172e6ff460b3
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        YfBucketAndTagOutbound yfBucketAndTagOutbound = yfBucketAndTagOutboundService.selectYfBucketAndTagOutboundById(id);
        mmap.put("yfBucketAndTagOutbound", yfBucketAndTagOutbound);
        return prefix + "/edit";
    }

    /**
     * 修改保存医废垃圾桶和条形码关联（一键出库）
     * 92d741e4-9828-48fb-8d32-3d5b227c6e2c
     */
    @RequiresPermissions("yf:outbound:edit")
    @Log(title = "医废垃圾桶和条形码关联（一键出库）", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YfBucketAndTagOutbound yfBucketAndTagOutbound)
    {
        return toAjax(yfBucketAndTagOutboundService.updateYfBucketAndTagOutbound(yfBucketAndTagOutbound));
    }

    /**
     * 删除医废垃圾桶和条形码关联（一键出库）
     * c5bae576-a3d3-44b4-b69f-4eda5385042f
     */
    @RequiresPermissions("yf:outbound:remove")
    @Log(title = "医废垃圾桶和条形码关联（一键出库）", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yfBucketAndTagOutboundService.deleteYfBucketAndTagOutboundByIds(ids));
    }
}
